package service

import (
	"context"
	"fmt"
	"go-mall/dao"
	"go-mall/model"
	"go-mall/pkg/e"
	"go-mall/serializer"
)

type NotificationService struct {
	model.BasePage
}

func (service *NotificationService) List(ctx context.Context) serializer.Response {
	code := e.Success
	notificationDao := dao.NewNotificationDao(ctx)
	notifications, err := notificationDao.ListNotification(service.BasePage)
	for _, item := range notifications {
		fmt.Printf("%v\n", item)
	}
	if err != nil {
		code = e.Error
		return serializer.Response{
			Status: code,
			Msg:    e.GetMsg(code),
		}
	}
	return serializer.BuildListResponse(serializer.BuildListNotification(notifications), uint(len(notifications)))
}
